﻿(function () {

  'use strict';
  goog.provide('Blockly.Blocks.LNSFAIoT_MQTT_Mixly');
  goog.require('Blockly.Blocks');

  var FieldMultilineInput;
  if (typeof Mixly === 'object') {
    FieldMultilineInput = Blockly.FieldMultilineInput;
  } else {
    FieldMultilineInput = Blockly.FieldTextArea;
  }
  Blockly.Blocks.LNSF_AIoTLOGO = {
    init: function () {
      this.appendDummyInput()
        .setAlign(Blockly.ALIGN_CENTRE)
        .appendField(new Blockly.FieldImage("../../media/LNSFAIoTwechat.jpg", 120, 120, "*"));
      this.setColour(90);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };
  
  Blockly.Blocks.LED_init = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LED_display.png", 25, 25, "*"))
        .appendField("初始化LED点阵屏总宽:")
        .appendField(new Blockly.FieldTextInput("64"), "weight")
        .appendField("px 总长:")
        .appendField(new Blockly.FieldTextInput("64"), "hight")
        .appendField("px 级联个数(行*列):")
        .appendField(new Blockly.FieldTextInput("1"), "row")
        .appendField("*")
        .appendField(new Blockly.FieldTextInput("1"), "col")
        .appendField("级联方式:")
        .appendField(new Blockly.FieldDropdown([[{ "src": "../../media/LED_stright.png", "width": 50, "height": 30, "alt": "*" }, "func1"], [{ "src": "../../media/Bottom_left_UPserpentine_chain.png", "width": 50, "height": 30, "alt": "*" }, "func2"], [{ "src": "../../media/Top-right_DOWN_serpentine_chain.png", "width": 50, "height": 30, "alt": "*" }, "func3"], [{ "src": "../../media/Vertical_serpentine_chain.png", "width": 50, "height": 30, "alt": "*" }, "func4"]]), "func");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#999999");
      this.setTooltip("确定好屏幕大小、级联个数。");
      this.setHelpUrl();
    }
  };



  Blockly.Blocks.LEDdisply = {
    init: function () {
      this.appendDummyInput()
        .appendField("显示样式: 字体:")
        .appendField(new Blockly.FieldDropdown([["华文黑体", "STHeiti"], ["华文楷体", "STKaiti"], ["华文细黑", "STXihei"], ["华文宋体", "STSong"], ["华文中宋", "STZhongsong"], ["华文仿宋", "STFangsong"], ["华文彩云", "STCaiyun"], ["华文琥珀", "STHupo"], ["华文隶书", "STLiti"], ["华文行楷", "STXingkai"], ["华文新魏", "STXinwei"], ["黑体", "simHei"], ["宋体", "simSun"], ["新宋体", "NSimSun"], ["仿宋", "FangSong"], ["楷体", "KaiTi"], ["仿宋_GB2312", "FangSong_GB2312"], ["楷体_GB2312", "KaiTi_GB2312"], ["隶书", "LiSu"], ["幼圆", "YouYuan"], ["新细明体", "PMingLiU"], ["细明体", "MingLiU"], ["标楷体", "DFKai-SB"], ["微软正黑体", "Microsoft JhengHei"], ["微软雅黑体", "Microsoft YaHei"], ["AcadEref", "AcadEref"], ["Adobe Ming Std L", "Adobe Ming Std L"], ["Adobe Myungjo Std M", "Adobe Myungjo Std M"], ["Adobe Pi Std", "Adobe Pi Std"], ["AIGDT", "AIGDT"], ["AIgerian", "AIgerian"], ["AmdtSymbols", "AmdtSymbols"], ["Arial", "Arial"], ["Arial Rounded MT Bold", "Arial Rounded MT Bold"], ["Arial Unicode MS", "Arial Unicode MS"], ["BankGothic Lt BT", "BankGothic Lt BT"], ["BankGothic Md BT", "BankGothic Md BT"], ["Baskerville Old Face", "Baskerville Old Face"], ["Bauhaus 93", "Bauhaus 93"], ["Beranad MT Condensed", "Beranad MT Condensed"]]), "hz_sharp")
        .appendField(" 字号:")
        .appendField(new Blockly.FieldTextInput([["11", "11"], ["12", "12"], ["14", "14"], ["16", "16"], ["18", "18"], ["20", "20"], ["22", "22"], ["24", "24"], ["26", "26"], ["28", "28"], ["36", "36"], ["48", "48"]]), "hz_line_height")
        .appendField("颜色:")
        .appendField(new Blockly.FieldColour("#ff0000"), "color")
        .appendField(" 代码区绘制图案")
        .appendField(new Blockly.FieldCheckbox("true"), "show_hz");
      this.appendDummyInput()
        .appendField("显示位置: 移动:")
        .appendField(new Blockly.FieldDropdown([["上移", "hz_up"], ["下移", "hz_down"]]), "hz_up_down")
        .appendField(new Blockly.FieldTextInput("0"), "hz_up_down_data")
        .appendField("像素 ")
        .appendField(new Blockly.FieldDropdown([["左移", "hz_left"], ["右移", "hz_right"]]), "hz_left_right")
        .appendField(new Blockly.FieldTextInput("0"), "hz_left_right_data")
        .appendField("像素")
        .appendField(" 点阵旋转")
        .appendField(new Blockly.FieldAngle(0), "bitmap_rotate");
      this.appendDummyInput()
        .appendField("显示字模数组(除中文外任意不重复数组名)")
        .appendField(new Blockly.FieldTextInput(""), "data_num")
        .appendField("的内容:")
        .appendField(new Blockly.FieldTextInput("岭师AIoT!"), "input_data");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#999999");
      this.setTooltip();
      this.setHelpUrl();
    }
  };

  Blockly.Blocks.LED_clear = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LED_display.png", 25, 25, "*"))
        .appendField("LED清屏");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#999999");
      this.setTooltip();
      this.setHelpUrl();
    }
  };

  Blockly.Blocks.LED_fill = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LED_display.png", 25, 25, "*"))
        .appendField("LED全屏填充")
        .appendField("颜色:")
        .appendField(new Blockly.FieldColour("#ff0000"), "color_fill");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#999999");
      this.setTooltip();
      this.setHelpUrl();
    }
  };

  Blockly.Blocks.LED_bright = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LED_display.png", 25, 25, "*"))
        .appendField("设置LED屏幕显示亮度")
        .appendField(new Blockly.FieldDropdown([["6", "192"], ["1", "32"], ["2", "64"], ["3", "96"], ["4", "128"], ["5", "160"], ["7", "224"], ["8", "230"]]), "LED_bright");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#999999");
      this.setTooltip("合理设置亮度");
      this.setHelpUrl();
    }
  };
  Blockly.Blocks.soil_PH = {
    init: function () {
      this.appendDummyInput()
        .setAlign(Blockly.ALIGN_CENTRE)
        .appendField("土壤PH值");
      this.setOutput(true, null);
      this.setColour("#993300");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.soil_WenDu = {
    init: function () {
      this.appendDummyInput()
        .setAlign(Blockly.ALIGN_CENTRE)
        .appendField("土壤温度(℃)");
      this.setOutput(true, null);
      this.setColour("#993300");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };


  Blockly.Blocks.soil_ShiDu = {
    init: function () {
      this.appendDummyInput()
        .setAlign(Blockly.ALIGN_CENTRE)
        .appendField("土壤湿度(%)");
      this.setOutput(true, null);
      this.setColour("#993300");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };


  Blockly.Blocks.soil_DianDaoLu = {
    init: function () {
      this.appendDummyInput()
        .setAlign(Blockly.ALIGN_CENTRE)
        .appendField("土壤电导率(us/cm)");
      this.setOutput(true, null);
      this.setColour("#993300");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };



  Blockly.Blocks.WIFI_init = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_WIFI.svg", 25, 25, "*"))
        .appendField("WiFi连接");
      this.appendValueInput("wifi_ssid")
        .setCheck(null)
        .setAlign(Blockly.ALIGN_CENTRE)
        .appendField("热点:");
      this.appendValueInput("wifi_password")
        .setCheck(null)
        .setAlign(Blockly.ALIGN_CENTRE)
        .appendField("密码:");
      this.setInputsInline(false);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(200);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };
  Blockly.Blocks.WiFi_connect= {
    init: function() {
    this.appendDummyInput()
        .appendField("WiFi连接状态");
    this.setInputsInline(true);
    this.setOutput(true, null);
    this.setColour(200);
    this.setTooltip("");
    this.setHelpUrl("");
    }
  };
  Blockly.Blocks.WIFI_init_yourSSID = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldMultilineInput("yourSSID"), "yourSSID");
      this.setOutput(true, null);
      this.setColour(200);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };


  Blockly.Blocks.WIFI_init_yourPASSWD = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldMultilineInput("yourPASSWD"), "yourPASSWD");
      this.setOutput(true, null);
      this.setColour(200);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };
  Blockly.Blocks.Aliyun_init = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_Aliyun.svg", 25, 25, "*"))
        .appendField("Aliyun连接");
      this.appendDummyInput()
        .appendField("ProductKey:")
        .appendField(new Blockly.FieldMultilineInput("ProductKey"), "ProductKey");
      this.appendDummyInput()
        .appendField("DeviceName:")
        .appendField(new Blockly.FieldMultilineInput("DeviceName"), "DeviceName");
      this.appendDummyInput()
        .appendField("DeviceSecret:")
        .appendField(new Blockly.FieldMultilineInput("DeviceSecret"), "DeviceSecret");
      this.appendDummyInput()
        .appendField("主题(Topic):");
      this.appendDummyInput()
        .appendField("Topic_0:")
        .appendField(new Blockly.FieldMultilineInput(""), "topic_0");
      this.appendDummyInput()
        .appendField("Topic_1:")
        .appendField(new Blockly.FieldMultilineInput(""), "topic_1");
      this.appendDummyInput()
        .appendField("Topic_2:")
        .appendField(new Blockly.FieldMultilineInput(""), "topic_2");
      this.appendDummyInput()
        .appendField("Topic_3:")
        .appendField(new Blockly.FieldMultilineInput(""), "topic_3");
      this.appendDummyInput()
        .appendField("Topic_4:")
        .appendField(new Blockly.FieldMultilineInput(""), "topic_4");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(99);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };



  Blockly.Blocks.Aliyun_keyvalue = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_Aliyun.svg", 25, 25, "*"))
        .appendField("json键值对:")
        .appendField(new Blockly.FieldMultilineInput("标识符"), "aliyun_key")
        .appendField("值(数值型)")
        .appendField(new Blockly.FieldMultilineInput("值"), "aliyun_value");
      this.setOutput(true, null);
      this.setColour(99);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.Aliyun_ADDkeyvalue = {
    init: function () {
      this.appendValueInput("keyvalue1")
        .setCheck(null);
      this.appendDummyInput()
        .appendField("和");
      this.appendValueInput("keyvalue2")
        .setCheck(null);
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setColour(99);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.Aliyun_publish = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_Aliyun.svg", 25, 25, "*"))
        .appendField("Aliyun上报");
      this.appendValueInput("publish_data")
        .setCheck(null);
      this.appendDummyInput()
        .appendField("至主题")
        .appendField(new Blockly.FieldDropdown([["Topic_0", "topic_0"], ["Topic_1", "topic_1"], ["Topic_2", "topic_2"], ["Topic_3", "topic_3"], ["Topic_4", "topic_4"]]), "topic1")
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(99);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.Aliyun_keyvalue_text = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldMultilineInput("键值对"), "keyvalue_text");
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setColour(99);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };


  Blockly.Blocks.Aliyun_received_news = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_Aliyun.svg", 25, 25, "*"))
        .appendField("当接收到Aliyun")
        .appendField(new Blockly.FieldDropdown([["Topic_0", "topic_0"], ["Topic_1", "topic_1"], ["Topic_2", "topic_2"], ["Topic_3", "topic_3"], ["Topic_4", "topic_4"]]), "topic3")
        .appendField("的消息");
      this.appendStatementInput("aliyun_callback")
        .setCheck(null);
      this.setColour(99);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };


  Blockly.Blocks.Aliyun_received_json = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_Aliyun.svg", 25, 25, "*"))
        .appendField("获取阿里云返回的信息")
        .appendField("标识符为")
        .appendField(new Blockly.FieldTextInput("identifier"), "identifier")
        .appendField("的参数值");
      this.setOutput(true, null);
      this.setColour(99);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.Readcomdata = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("(语音识别)循环读取su-03t串口数据")
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(90);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.comdata = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("(语音识别)su_03t的串口数据 = ")
        .appendField(new Blockly.FieldMultilineInput("A1"), "serialdata")
      this.setOutput(true, null);
      this.setColour(90);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.SendFrameHead = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("(语音播报)")
        .appendField("发送帧头")
        .appendField(new Blockly.FieldMultilineInput("AA55"), "header")
        .appendField("(消息编号)")
        .appendField(new Blockly.FieldMultilineInput("1"), "new_num")
        .appendField("(十六进制字符之间无需空格隔开)");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(90);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.SendChar = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("(语音播报)")
        .appendField("发送char参数值")
        .appendField(new Blockly.FieldMultilineInput("22"), "chardata");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(90);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };


  Blockly.Blocks.SendInt = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("(语音播报)")
        .appendField("发送int参数值")
        .appendField(new Blockly.FieldMultilineInput("22"), "intdata");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(90);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };


  Blockly.Blocks.Sendunsigndechar = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("(语音播报)")
        .appendField("发送unsignde char参数值")
        .appendField(new Blockly.FieldMultilineInput("22"), "unsigndechardata");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(90);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };


  Blockly.Blocks.SendTail = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("(语音播报)")
        .appendField("发送帧尾")
        .appendField(new Blockly.FieldMultilineInput("55AA"), "tail")
        .appendField("(十六进制字符之间无需空格隔开)");
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour(90);
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };




  Blockly.Blocks.serial_read = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("读取多合一空气质量传感器(RJ485)采集的数据");
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#3366ff");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.LNSFAIoT_parameter = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("空气质量中")
        .appendField(new Blockly.FieldDropdown([["温度值(℃)", "LNSFAIoT_air_num_WenDu"], ["湿度值(%)", "LNSFAIoT_air_num_ShiDu"], ["PM10含量(ug/m3)", "LNSFAIoT_air_num_PM10"], ["二氧化碳气体(CO2)含量(ppm)", "LNSFAIoT_air_num_CO2"], ["甲醛气体(CH2O)含量(ug/m3)", "LNSFAIoT_air_num_CH2O"], ["总挥发性有机化合物(TVOC)含量(ug/m3)", "LNSFAIoT_air_num_TVOC"], ["PM2.5含量(ug/m3)", "LNSFAIoT_air_num_PM25"]]), "LNSFAIoT_enum_parameter");
      this.setInputsInline(true);
      this.setOutput(true, null);
      this.setColour("#3366ff");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };

  Blockly.Blocks.serial_println = {
    init: function () {
      this.appendDummyInput()
        .appendField(new Blockly.FieldImage("../../media/LNSF_AIoT_LOGO.svg", 25, 20, "*"))
        .appendField("串口0打印显示多合一空气质量传感器(RJ485)采集的数据");
      this.setInputsInline(true);
      this.setPreviousStatement(true, null);
      this.setNextStatement(true, null);
      this.setColour("#3366ff");
      this.setTooltip("");
      this.setHelpUrl("");
    }
  };



})();